package com.biyeshengjiuye.service.impl;

import com.biyeshengjiuye.dao.AdminMapper;
import com.biyeshengjiuye.entity.Admin;
import com.biyeshengjiuye.service.AdminService;
import com.biyeshengjiuye.utils.PasswordUtil;
import com.biyeshengjiuye.utils.SystemConstant;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class AdminServiceImpl implements AdminService {

    @Resource
    private AdminMapper adminMapper;


    public Admin login(String loginId, String loginPwd) {
        Admin admin = adminMapper.findAdminById(loginId);
        if (admin != null){
            String newPassword = PasswordUtil.md5(loginPwd,loginId, SystemConstant.PASSWORD_COUNT);
            if (admin.getPassword().equals(newPassword)){
                return admin;
            }
        }
        return null;
    }

}
